using NUnit.Framework;
using Tycho.Grammar;
using Tycho.Parser.Peg;
using Tycho.Parser.Tests.Peg;

namespace Tycho.UnitTests.Grammar {
    [TestFixture]
    public class KeywordSpecification {
        [Test]
        public void ShouldParseSequence () {
            IProduction production = GrammarLoader.CreateKeyword ();

            ITerm t = production.ParseTerm ("'keyword'");
            Assert.IsNotNull (t);
            var term = t as CompositeTerm;
            Assert.IsNotNull (term);
            Assert.AreEqual ("keyword", term.Name);
            Assert.AreEqual (1, term.SubTerms.Count);
            Assert.AreEqual ("keyword", ((StringTerm) term.SubTerms["name"]).Value);
        }

        [Test]
        public void ShouldNotParse () {
            IProduction production = GrammarLoader.CreateKeyword ();

            production.AssertNotParsed ("a");
            production.AssertNotParsed ("\"key\"");
        }
    }
}